﻿using UnityEngine;
using System.Collections;

//将方法作为方法的参数 + 将方法绑定到委托
public class delegate_test_one : MonoBehaviour
{
    public delegate void delegateSay(string name, int age);

    public void Say(string name,int age,delegateSay sy)
    {
        sy(name, age);
    }

    public void ChineSay(string name,int age)
    {
        Debug.LogError("chinese name:"+name + "age:" + age.ToString());
    }
   
    public void EnglishSay(string name,int age)
    {
        Debug.LogError("english name:" + name + "age:" + age.ToString());
    }

    //将方法作为方法的参数
    public void chineseClicked()
    {
        Say("五颗星", 78, ChineSay);
    }

    public void englishClicked()
    {
        Say("caojianlin", 29, EnglishSay);
    }

    //将方法绑定到委托
    public void ClickToMore()
    {
        delegateSay deleSay = new delegateSay(ChineSay);
        deleSay += EnglishSay;
        Say("caojianlin",30, deleSay);
    }

}




